package com.yyp.car.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.hdw.basic.dao.BaseDao;
import com.yyp.car.Idao.IStudentDao;
import com.yyp.car.model.Student;
@Repository("studentDao")
public class StudentDao extends BaseDao<Student> implements IStudentDao{

	@Override
	public Student findByIdNumber(String idNumber) {
		String hql = "from Student s where s.idNumber=?";
		return (Student) this.queryObject(hql, idNumber);
	}

	@Override
	public void updateByTestType(int id, String testType) {
		String hql="update Student s set s.testType='"+testType+"' where s.id='"+id+"'";
		this.getSession().createQuery(hql).executeUpdate();
	}

	@Override
	public void delTestType(int id) {
		String hql="update Student s set s.testType='"+null+"' where s.id='"+id+"'";
		this.getSession().createQuery(hql).executeUpdate();
		
	}

	@Override
	public String findTestType(int id) {
		String hql="select s.testType from Student s where s.id='"+id+"'";
		return (String)this.queryObject(hql);
	}

	@Override
	public List<Student> listStudent() {
		String hql="from Student";
		return this.list(hql);
	}

	@Override
	public void updateTestMes(int id,String testPlace, String beginTime, String endTime) {
		String hql="update Student s set s.testPlace='"+testPlace+"',s.beginTime='"+beginTime+"',s.endTime='"+endTime+"' where s.id='"+id+"'";
		this.updateByHql(hql);
	}

	@Override
	public Student findTestMes(int id) {
		String hql="select new Student(s.testPlace,s.beginTime,s.endTime) from Student s where s.id='"+id+"'";
		return (Student)this.queryObject(hql);
	}

	@Override
	public void cancleTestMes(int id) {
		String hql="update Student s set s.testPlace=null,s.beginTime=null,s.endTime=null where s.id='"+id+"'";
		this.updateByHql(hql);
	}

	@Override
	public Student findStudet(int id) {
		String hql="from Student s where s.id='"+id+"'";
		return (Student)this.queryObject(hql);
	}

	
}
